package com.project.service.service;

import com.project.service.bean.UserBean;
import com.project.service.dao.IUserDao;
import com.project.service.server.Request;
import com.project.service.server.Response;
import com.project.service.server.Servlet;
import com.project.service.util.DaoFactory;
import com.project.service.util.WebServlet;

/**
 * 登陆业务组件
 */
@WebServlet("land")
public class LoginService implements Servlet {
    /**持久组件*/
    private IUserDao dao = (IUserDao) DaoFactory.getDao("IUserDao");

    /**
     * 业务方法，处理登陆
     * @param request 请求对象
     * @param response 响应对象
     */
    public void service(Request request, Response response){
        //得到表单数据
        String userName = request.getParameter("userName");
        String pwd = request.getParameter("pwd");

        //调用持久组件，得到登陆结果
        UserBean user = dao.login(userName,pwd);
        if(user != null){
            response.sendMessage("登陆成功");
        }
        else{
            response.sendMessage("登陆失败");
        }
    }
}
